package functions;
import types.SubSet;
import functions.NCD;

// get standard deviation of a sub set
public class STD {
	public static Double getSTD(SubSet set)
	{
		double sum = 0.0;
		double result = 0.0;
		double dis = 0.0;
		int n = set.getSize();
		String medoid = set.getBestMedoid();
		for (int i=0; i<n; i++){
			dis = NCD.getNCD(set.getElement(i), medoid);
			dis = Math.pow(dis,2);
			sum = sum + dis;			
		}
		result = sum/(n-1);
		result = Math.sqrt(result);				
		return result;		
	}
}
